// functionPage/components/review-input/review-input.js
import Http from '../../../utils/http.js';
const http = new Http();
const app = getApp();

Component({
    /**
     * 组件的属性列表
     */
    properties: {},

    /**
     * 组件的初始数据
     */
    data: {
        index: 0, //审核后刷新数量
        list: [],
        deleteCnt: '', //删除的数量
        recommendCnt: '', //推优数
        unVerifyCnt: '', //未审核数量
        verifyCnt: '', //已审核数量
        PageNo: 0,
        ContentLength: Number,
        Loading: true,
        typeValue: [
            {
                name: '录入了FT测试点',
                type: '01',
                path: '/pages/homePageInfo/ftInfo/ftInfo?',
            },
            {
                name: '录入了NFC测试点',
                type: '02',
                path: '/pages/homePageInfo/nfcInfo/nfcInfo?',
            },
            {
                name: '录入了FT测试路线',
                type: '03',
                path: '/pages/homePageInfo/ftRouteInfo/ftRouteInfo?',
            },
            {
                name: '录入了NFC测试路线',
                type: '04',
                path: '/pages/homePageInfo/nfcRouteInfo/nfcRouteInfo?',
            },
            {
                name: '发布了城市公告',
                type: '06',
                path: '/functionPage/pages/secretary/noticeInfo/noticeInfo?',
            },
            {
                name: '发起了互动问答',
                type: '08',
                path:
                    '/pages/notice/projectTeam/interactiveQuestionAndAnswer/interactiveQuestionAndAnswer?',
            },
            {
                name: '发布了租车推荐',
                type: '11',
                path: '/functionPage/pages/cszxDetail/cszxDetail?type=01&',
            },
            {
                name: '发布了住宿推荐',
                type: '12',
                path: '/functionPage/pages/cszxDetail/cszxDetail?type=03&',
            },
            {
                name: '发布了出行建议',
                type: '13',
                path: '/functionPage/pages/cszxDetail/cszxDetail?type=04&',
            },
            {
                name: '发布了美食推荐',
                type: '14',
                path: '/functionPage/pages/cszxDetail/cszxDetail?type=02&',
            },
            {
                name: '发布了营业厅信息',
                type: '15',
                path: '/pages/homePageInfo/business-hall/business-hall?',
            },
            {
                name: '录入基站参数',
                type: '16',
                path: '/functionPage/pages/review/networkType/networkType?',
            },
            {
                name: '新建了运营商',
                type: '17',
                path:
                    '/functionPage/pages/review/operatorDetail/operatorDetail?',
            },
            {
                name: '新建了套餐建议',
                type: '18',
                path: '/functionPage/pages/review/packageDetail/packageDetail?',
            },
        ],
    },
    lifetimes: {
        attached: function () {
            // 在组件实例进入页面节点树时执行
            this.getVerifyList();
        },
    },
    /**
     * 组件的方法列表
     */
    methods: {
        jumpPageTap(e) {
            let url;
            this.setData({
                index: e.currentTarget.dataset.index,
            });
            //review     01-----待审核      02-----审核后
            if (e.currentTarget.dataset.delflg == '02') {
                url =
                    e.currentTarget.dataset.path +
                    'review=01&id=' +
                    e.currentTarget.dataset.id +
                    '&infoId=' +
                    e.currentTarget.dataset.ftid +
                    '&operatorid=' +
                    e.currentTarget.dataset.operatorid;
            } else {
                url =
                    e.currentTarget.dataset.path +
                    'review=02&id=' +
                    e.currentTarget.dataset.id +
                    '&infoId=' +
                    e.currentTarget.dataset.ftid +
                    '&operatorid=' +
                    e.currentTarget.dataset.operatorid;
            }
            console.log(url);
            wx.navigateTo({
                url: `${url}`,
            });
        },
        getVerifyList() {
            let _that = this;
            if (
                _that.data.PageNo != 0 &&
                _that.data.ContentLength == _that.data.list.length
            )
                return;
            _that.setData({
                Loading: true,
                PageNo: _that.data.PageNo + 1,
            });
            let data = {
                authId: app.globalData.authId,
                pageNo: _that.data.PageNo,
                pageSize: 20,
            };
            http.getRequest(`cjMap/getVerifyList`, data).then((res) => {
                if (res.status == 0) {
                    for (let i = 0; i < res.data.length; i++) {
                        //type:  01录入了FT测试点 02录入了NFC测试测试点 03录入了FT测试路线 04录入了NFC测试路线 06发布了xx城市公告 08发起了互动问答11发布了租车推荐 12发起了住宿推荐 13发布了出行建议 14发起了美食推荐 15发起了营业厅信息 16录入基站参数 17新建运营商  18新建套餐建议
                        res.data[i].updatetime = app.timeago(
                            res.data[i].updatetime
                        );
                        for (let j = 0; j < _that.data.typeValue.length; j++) {
                            if (
                                _that.data.typeValue[j].type == res.data[i].type
                            ) {
                                res.data[i].typeValue =
                                    _that.data.typeValue[j].name;
                                res.data[i].path = _that.data.typeValue[j].path;
                            }
                        }
                        _that.data.list.push(res.data[i]);
                    }
                    _that.setData({
                        list: _that.data.list,
                        deleteCnt: res.typeCnt.deleteCnt, //删除的数量
                        recommendCnt: res.typeCnt.recommendCnt, //推优数
                        unVerifyCnt: res.typeCnt.unVerifyCnt, //未审核数量
                        verifyCnt: res.typeCnt.verifyCnt, //已审核数量
                        Loading: false,
                        ContentLength: res.pager.totalRows,
                    });
                }
            });
        },
        // 审核后刷新
        refresh() {
            let _that = this;
            let data = {
                authId: app.globalData.authId,
                pageNo: 1,
                pageSize: _that.data.index + 10,
            };
            http.getRequest(`cjMap/getVerifyList`, data).then((res) => {
                if (res.status == 0) {
                    for (let i = 0; i < res.data.length; i++) {
                        if (
                            res.data[i].originid ==
                            _that.data.list[_that.data.index].originid
                        ) {
                            _that.data.list[_that.data.index].delflg =
                                res.data[i].delflg;
                            _that.data.list[_that.data.index].id =
                                res.data[i].id;
                            _that.data.list[_that.data.index].verifyname =
                                res.data[i].verifyname;
                            _that.data.list[_that.data.index].verifyflg =
                                res.data[i].verifyflg;
                            break;
                        }
                    }
                    _that.setData({
                        list: _that.data.list,
                        deleteCnt: res.typeCnt.deleteCnt, //删除的数量
                        recommendCnt: res.typeCnt.recommendCnt, //推优数
                        unVerifyCnt: res.typeCnt.unVerifyCnt, //未审核数量
                        verifyCnt: res.typeCnt.verifyCnt, //已审核数量
                    });
                }
            });
        },
    },
});
